package com.hs.hlw.credit.system.data.util;

import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.hs.hlw.credit.system.data.mybatis.Pageable;
import com.hs.hlw.credit.system.data.primary.model.SubmissionFormField;
import com.hualongdata.exception.BusinessException;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

/**
 * DbUtil
 * @author zhb
 * @date 2018/11/21
 */
public interface DbUtil {
    /**
     * 删除
     * @param tableName
     * @param whereList
     * @throws Exception
     */
    void delete(String tableName, List<SubmissionFormField> whereList) throws BusinessException;

    /**
     * 保存数据
     * @param tableName
     * @param fieldList
     * @param data
     */
    void insert(String tableName, List<SubmissionFormField> fieldList, JsonArray data) throws Exception;

    /**
     * 更新
     * @param tableName
     * @param fieldList
     * @param data
     * @param where
     */
    void update(String tableName, List<SubmissionFormField> fieldList, JsonObject data, String where) throws Exception;

    /**
     * 根据sql查询数据
     * @param sql
     * @return
     * @throws SQLException
     */
    List<Map<String, Object>> selectBySql(String sql) throws SQLException;

    /**
     * 分页查询
     * @param tableName
     * @param fieldList
     * @param whereList
     * @param pageable
     * @return
     * @throws SQLException
     */
    List<Map<String, Object>> page(String tableName, List<SubmissionFormField> fieldList, List<SubmissionFormField> whereList, Pageable pageable) throws BusinessException;
}